# 大类：经营状况
# 小类：招聘信息

import json
import time


# 18-招聘数据-2018-05-26
def get_zhaopin(mongo_instance, soup, cid, company):
    print('start 招聘数据*******')
    if soup.find('div', attrs={'tyc-event-ch': 'CompangyDetail.zhaopin'}):
        scripts = soup.find('div', attrs={'tyc-event-ch': 'CompangyDetail.zhaopin'}).find_all('script')
        for script in scripts:
            item = json.loads(script.text)
            print(item)

            item['create_at'] = int(time.time())
            item['update_at'] = item['create_at']
            item['company'] = company
            item['company_id'] = cid
            mongo_instance.zhaopin.update({'company_id': cid}, item, True)

    print('success 招聘数据*******')
